<!DOCTYPE HTML>

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sf.json.JSONArray" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<jsp:useBean id="StatisticComInfo" class="weaver.meeting.search.StatisticComInfo" scope="page" />
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page" />
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<%	
 	StatisticComInfo.setTimeSag(6); 
 	StatisticComInfo.setSubIds(request.getParameter("subIds"));
 	StatisticComInfo.setBegindate(request.getParameter("begindate"));
 	StatisticComInfo.setEnddate(request.getParameter("enddate"));
 	int totalTimes=Util.getIntValue(request.getParameter("total"),-1);
 	int mode=Util.getIntValue(request.getParameter("mode"));
    String searchSql="SELECT t1.id,t1.name,t1.subcompanyid,count(1) as times  ";
    String tableSql="FROM MeetingRoom t1,meeting t2";
    String whereSql=" where t1.id=t2.address and (t1.status=1 or t1.status is null )  and t2.repeatType = 0 ";
    //页面的其他条件
    whereSql+=StatisticComInfo.getMeetingUsedSql();
    
    String groupSql=" group by t1.id,t1.name,t1.subcompanyid ";
     
    //计算每个会议室使用次数
    rs.executeSql(searchSql+tableSql+whereSql+groupSql);
    Map map=null;
    List list=new ArrayList();
    String name="";
    while(rs.next()){
   		map= new HashMap();
    	map.put("name",rs.getString("name")+"("+SubCompanyComInfo.getSubCompanyname(rs.getString("subcompanyid"))+")");
    	map.put("y",totalTimes==0?0:rs.getInt("times")*100.0/totalTimes);
    	list.add(map);
    }
    String jsonStr=JSONArray.fromObject(list).toString();
%>
<HTML>
  <HEAD>
  </HEAD>
  <BODY width=100% height=100%>
     <div id="MeetingUsedDiv" style="min-width: 400px; height: 450px;"></div>
 </BODY>
<script type="text/javascript" src="/js/highcharts/highcharts_wev8.js"></script>
<script type="text/javascript" src="/js/highcharts/modules/no-data-to-display_wev8.js"></script>
<SCRIPT LANGUAGE="JavaScript">

	var isInternetExplorer = navigator.userAgent.indexOf('MSIE') != -1;
	 
 	var mode="<%=mode%>";
	var jsonStr='<%=jsonStr%>';
	var jsonData=eval('('+jsonStr+')');
	if(isInternetExplorer){
		setTimeout('showMeetingUsedDiv()',mode==0?500:1500);
	}else{
		setTimeout('showMeetingUsedDiv()',10);
	}
 
	function showMeetingUsedDiv(){
   	// Build the chart
       $('#MeetingUsedDiv').highcharts({
           chart: {
               plotBackgroundColor: null,
               plotBorderWidth: null,
               plotShadow: false,
               //borderColor: '#DADADA',
              borderWidth:0
           },
           title: {
               text: "<%=SystemEnv.getHtmlLabelName(32527,user.getLanguage()) %>",
               style: {
					color: '#000000',//#3E576F',
					fontSize: '24px'
				}
           },
           tooltip: {
       	    pointFormat: '<b>{point.percentage:.2f}%</b>'
           },
           plotOptions: {
               pie: {
                   allowPointSelect: true,
                   cursor: 'pointer',
                   dataLabels: {
                       enabled: true,
                       color: '#000000',
	                   connectorColor: '#000000',
	                   distance: 30,
	                   format: '<b>{point.percentage:.2f}%</b>'
                   },
                   showInLegend: true
               }
           },
           series:[{
               type: 'pie',
               name: '<%=SystemEnv.getHtmlLabelName(32527,user.getLanguage()) %>',
               data:  jsonData
           }] ,
           credits: {
			enabled: false
		},       
        lang: {
           noData: "<%=SystemEnv.getHtmlLabelName(26161,user.getLanguage())+SystemEnv.getHtmlLabelName(563,user.getLanguage()) %>"
        }
       });
      }

</SCRIPT>